/*
 *     The Peacock Project - a HITMAN server replacement.
 *     Copyright (C) 2021-2024 The Peacock Project Team
 *
 *     This program is free software: you can redistribute it and/or modify
 *     it under the terms of the GNU Affero General Public License as published by
 *     the Free Software Foundation, either version 3 of the License, or
 *     (at your option) any later version.
 *
 *     This program is distributed in the hope that it will be useful,
 *     but WITHOUT ANY WARRANTY; without even the implied warranty of
 *     MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 *     GNU Affero General Public License for more details.
 *
 *     You should have received a copy of the GNU Affero General Public License
 *     along with this program.  If not, see <https://www.gnu.org/licenses/>.
 */

import * as React from "react"
import "infima/dist/css/default/default.css"
import "./App.css"
import { createBrowserRouter, RouterProvider } from "react-router-dom"
import { DevToolsPage } from "./pages/DevToolsPage"
import { TransferPage } from "./pages/TransferPage"
import { LoadoutPage } from "./pages/LoadoutPage"
import { RootPage } from "./pages/RootPage"
import { Home } from "./pages/Home"
import { EscalationLevelPage } from "./pages/EscalationLevelPage"

const router = createBrowserRouter([
    {
        path: "/",
        element: <RootPage />,
        children: [
            {
                path: "",
                element: <Home />,
            },
            WEBUI_IS_DEV
                ? {
                      path: "ui/devtools",
                      element: <DevToolsPage />,
                  }
                : null!,
            {
                path: "ui/transfer",
                element: <TransferPage />,
            },
            {
                path: "ui/loadouts",
                element: <LoadoutPage />,
            },
            {
                path: "ui/escalations",
                element: <EscalationLevelPage />,
            },
            {
                path: "*",
                element: (
                    <h1 style={{ marginTop: "4rem", textAlign: "center" }}>
                        Not Found
                    </h1>
                ),
            },
        ].filter(Boolean),
    },
])

export function App(): React.ReactElement {
    return <RouterProvider router={router} />
}
